package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.GradeBean;
import com.project.bean.RoleBean;
import com.project.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private IRoleService roleService;
    @RequestMapping("findByRoleArr")
    public List<GradeBean> findByRoleArr(Integer[] roles){
       return   roleService.findByRoleArr(roles);
    };

    @RequestMapping("cutAll")
    public IPage<RoleBean> cutAll (Integer pageNO){
        return roleService.cutAll(pageNO);
    };
    @RequestMapping("findAll")
    public List<RoleBean> findAll(){
        return roleService.findAll();
    };
    @RequestMapping("add")
    public String  add(RoleBean roleBean,Integer[] gradeArr){
        roleService.add(roleBean,gradeArr);

        return "ok";
    }

    @RequestMapping("del")
    public String del(Integer roleId){
        roleService.del(roleId);
        return "ok";
    };

    @RequestMapping("findById")
    public RoleBean findById(Integer roleId){
        return roleService.findById(roleId);
    };
    @RequestMapping("update")
    public String update(Integer roleId,Integer[] gradeIds){
        roleService.update(roleId,gradeIds);
        return "ok";
    };
}
